//
//  BaseModel.m
//  UI_豆瓣
//
//  Created by Marry W. on 15/12/24.
//  Copyright © 2015年 www.lanou3g.com 蓝鸥科技. All rights reserved.
//

#import "BaseModel.h"

@implementation BaseModel
- (instancetype)initWithDic:(NSDictionary *)dic
{
    self = [super init];
    if (self) {
        [self setValuesForKeysWithDictionary:dic];
    }
    return self;
}
+ (instancetype)modelWithDic:(NSDictionary *)dic
{
    // [self class]表示当前类
    id m = [[[self class] alloc] initWithDic:dic];
    return m;
}
+ (NSMutableArray *)modelHandlerWithArray:(NSArray *)arr
{
    // 1.创建空数组 保存处理后的model对象
    NSMutableArray *mArr = [NSMutableArray array];
    // 2.遍历传入的数组参数 得到每个字典信息
    for (NSDictionary *dic in arr) {
        // 3.使用KVC转化为对象
        id m = [[self class] modelWithDic:dic];
        // 4.添加到数组
        [mArr addObject:m];
    }
    return mArr;
}
- (void)setValue:(id)value forUndefinedKey:(nonnull NSString *)key
{
    
}
@end
